/**
 * @author (Jeff Thomas) 
 * @version (10.25.2007)
 */

import java.util.*;

public class TimeSpan {
    private int hours;
    private int minutes;

    public TimeSpan() {
        hours = 0;
        minutes = 0;
    }
    public TimeSpan(int hrs, int min) {
        hours = hrs;
        minutes = min;
    }
    
    public int getHours() {
        return hours;
    }
    public int getMinutes() {
        return minutes;
    }
    
    public TimeSpan add(int hrs, int min) {
        this.hours = this.hours + hrs;
        this.minutes = this.minutes + min;
        if (this.minutes > 60) {
            this.hours += (int) this.minutes / 60;
            this.minutes = this.minutes % 60;
        }
        return this;
    }
    public TimeSpan add(TimeSpan time) {
        this.add(time.hours, time.minutes);
        return this;
    }
    
    public double getTotalHours() {
        return this.hours + (this.minutes / 60.0);
    }
    
    public String toString() {
        String temp = this.hours + "h" + this.minutes + "m";
        return temp;
    }
    
    public boolean equals(TimeSpan time) {
        final double EPSILON = 0.01;
        return (Math.abs(this.hours - time.hours) <= EPSILON && Math.abs(this.minutes - time.minutes) <= EPSILON);
    }
}
